<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>个人中心</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css"/>
    <link rel="stylesheet" type="text/css" href="./css/mui.min.css">
    <link rel="stylesheet" type="text/css" href="./css/base.css">
    <link rel="stylesheet" type="text/css" href="./css/weui.min.css">
    <link rel="stylesheet" type="text/css" href="./css/CFNetPP_Base.css">
    <style>
        html, body {
            background-color: #f3f5f7;
            overflow: hidden;
        }

        .bg {
            position: relative;
            width: 100%;
            height: 158px;
            text-align: center;
            background-color: #34394b;
        }

        .bgimg {
            width: 100%;
            height: 190px;
            position: relative;
            text-align: center;
        }

        .jiantou {
            height: 20px;
        }

        .superIconFrame {
            width: 66px;
            height: 66px;
            border-radius: 33px;
            border: solid 1px white;
            position: absolute;
            top: 26px;
            left: calc(50% - 33px);
        }

        .iconframe {
            width: 64px;
            height: 64px;
            border-radius: 32px;
            /* border: solid 2px white; */
            /* position: absolute; */
            /* top: 30px; */
            /* left: 42%; */
            margin-left: 0px;
            margin-top: 0px;
        }

        .name {
            width: 100%;
            text-align: center;
            position: absolute;
            color: white;
            font-size: 16px;
            /* left: 36%; */
            bottom: 34px;
        }

        .school {
            width: 100%;
            text-align: center;
            position: absolute;
            color: white;
            font-size: 12px;
            /* left: 36%; */
            bottom: 12px;
        }

        .cellHeight {
            height: 38px;
            position: relative;
        }

        .cell_img {
            position: absolute;
            width: 20px;
            height: 20px;
            bottom: 12px;
        }

        .rightDerection {
            position: absolute;
            width: 7px;
            height: 13px;
            margin-bottom: 15px;
            right: 15px;
        }

        .cacheSize {
            position: absolute;
            bottom: 12px;
            width: 70px;
            height: 20px;
            font-size: 14px;
            text-align: right;
            /* right: 35px; */
            right: 15px;
        }

        .menutitle {
            position: absolute;
            bottom: 8px;
            font-size: 14px;
            margin-left: 33px;
        }

        .bottom0 {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 49px;
            border-top: solid 1px #ededed;
            line-height: 49px;
            background-color: #ff9900;
        }

        .fontColor {
            color: #333333;
        }

        .mui-navigate-right:after, .mui-push-left:after, .mui-push-right:after {
            font-size: 20px;
            font-weight: 700;
        }

        .mui-navigate-right:after, .mui-push-left:after, .mui-push-right:after {
            color: #cdd0d5;
        }

        .titleSet {
            padding-left: 30px;
            font-size: 14px;
        }

        .back-btn-div {
            position: absolute;
            width: 44px;
            height: 44px;
            top: 22px;
            left: 0px;
            padding: 12px;
        }

        .base_right_reddiv {
            top: 12px;
            left: 100px;
            width: 5px;
            height: 5px;
        }

        .seize-a-seat-div {
            height: 49px;
        }
    </style>
</head>
<body>
<div class="main">
    <div class="bg">
        <!-- #333A4B -->
        <!-- <img class="bgimg" src="./image/bg_big.png" alt=""> -->
        <div class="back-btn-div" onclick="backToMain()">
            <img id="jiantou" class="jiantou" src="./image/icon_jiantou.png" alt="">
        </div>
        <div class="superIconFrame">
            <!-- ./image/default_user_icon.png -->
            <img id="usericon" class="iconframe" src="./icon/icon_default_HeadPortrait.png" alt=""
                 onclick="replaceImg()">
        </div>
        <div id="user_name" class="name"></div>
        <div id="user_school" class="school"></div>
    </div>
    <ul class="mui-table-view">
        <!-- onclick="click(1)" -->
        <li id="my_qiehuanjituan" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_jituan.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    集团切换
                </div>
            </a>

        </li>
        <li id="my_qiehuanshenfen" class="mui-table-view-cell mui-media">
            <a href="javascript:;"> <img class="cell_img" src="./icon/icon_shenfen.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    身份切换
                </div>
            </a>
            <span id="my_shenfen" class="cacheSize" style="color:#b0b0b0;">教师</span>
        </li>
        <li id="my_info" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_xinxipng.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    个人信息
                </div>
            </a>
        </li>
        <li id="my_face" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_xinxipng.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    人脸认证
                </div>
            </a>
        </li>
        <!--<li  id="my_jifen" class="mui-table-view-cell mui-media" style="display: none;">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/jifen_icon.png">
            <div class="mui-media-body base_dark_grey titleSet">
                我的积分
            </div> </a>
        </li>-->
        <li id="my_competition" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_competition.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    我的竞赛
                </div>
            </a>
        </li>
        <li id="my_pay" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./image/ico_pay_buy.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    我的支付
                </div>
            </a>
        </li>
        <li id="my_application" class="mui-table-view-cell mui-media" style="display: none;">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_application.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    我的应用
                </div>
            </a>
        </li>
        <li id="my_PersonalTrajectory" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_zuji.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    积分足迹
                </div>
            </a>
        </li>
        <!-- <li id="my_study" class="mui-table-view-cell cellHeight" >
        <img class="cell_img" src="./icon/icon_xuexi.png" alt="">
        <span class="base_grey menutitle">我的学习</span>
        <img class="rightDerection" src="./icon/icon_fanjt.png" alt="">
        </li>
        <li id="my_shezhi" class="mui-table-view-cell cellHeight" >
        <img class="cell_img" src="./icon/icon_shixi.png" alt="">
        <span class="base_grey menutitle">我的实习</span>
        <img class="rightDerection" src="./icon/icon_fanjt.png" alt="">
        </li>
        <li id="my_renzheng" class="mui-table-view-cell cellHeight" >
        <img class="cell_img" src="./icon/icon_renzheng.png" alt="">
        <span class="base_grey menutitle">我的认证</span>
        <img class="rightDerection" src="./icon/icon_fanjt.png" alt="">
        </li>
        <li id="my_message" class="mui-table-view-cell cellHeight"  >
        <img class="cell_img" src="./icon/icon_xiaoxi.png" alt="" >
        <span class="base_grey menutitle">我的消息</span>
        <img class="rightDerection" src="./icon/icon_fanjt.png" alt="">
        </li> -->
        <li id="suggestBack" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_fankui.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    反馈意见
                </div>
            </a>
        </li>
        <li id="my_cache" class="mui-table-view-cell mui-media">
            <a href="javascript:;"> <img class="cell_img" src="./icon/icon_qingchu.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    清除缓存
                </div>
            </a>
            <span id="cacheValue" class="cacheSize" style="color:#b0b0b0;">0 B</span>
        </li>
        <!--<li  id="my_shenqing" class="mui-table-view-cell mui-media" style="display: none;">
        <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./image/icon_shenqing.png">
        <div class="mui-media-body base_dark_grey titleSet">
        长风模式体验申请
        </div> </a>
        </li>
        <li  id="my_cfnetxingxing" class="mui-table-view-cell mui-media" style="display: none;">
        <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./image/icon_my_xingxing.png"> <div id="redPoint_xuexi_div1" class="redPointMessage base_right_reddiv" ></div>
        <div class="mui-media-body base_dark_grey titleSet">
        长风之星
        </div> </a>
        </li>-->
        <li id="my_about" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="./icon/icon_guanyu.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    关于
                </div>
            </a>
        </li>
        <li id="my_join" class="mui-table-view-cell mui-media">
            <a class='mui-navigate-right' href="javascript:;">
                <img class="cell_img" src="./image/icon_join.png">
                <div class="mui-media-body base_dark_grey titleSet">
                    加入我们
                </div>
            </a>
        </li>
    </ul>
    <div class="seize-a-seat-div"></div>
    <div class=" bottom0" id="offline_btn" onclick="tuichu()">
        <div class=" base_title_font " style="text-align: center;color: #FFFFFF">
            退出账号
        </div>
    </div>
    <!--  <div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
    <div class="weui_dialog_hd"><strong class="weui_dialog_title">确定退出登录？</strong></div>
    <div class="weui_dialog_ft">
    <a href="javascript:cleanCancel();" class="weui_btn_dialog default" style="color:#18b4ed">取消</a>
    <a  href="javascript:cleanConfirm();" class="weui_btn_dialog primary" style="color:#18b4ed">确定</a>
    </div>
    </div>
    </div>-->
    <div id="cleanCache" class="weui_dialog_confirm" style="display: none;">
        <div class="weui_mask"></div>
        <div class="weui_dialog">
            <div class="weui_dialog_hd">
                <strong class="weui_dialog_title">确定清除缓存？</strong>
            </div>
            <div class="weui_dialog_bd"></div>
            <div class="weui_dialog_ft">
                <a onclick="cancleCache()" href="#" class="weui_btn_dialog default" style="color:#18b4ed">取消</a>
                <a onclick="confirmCache()" href="#" class="weui_btn_dialog primary" style="color:#18b4ed">确定</a>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/jquery.min.js"></script>
<script type="text/javascript" src="./script/MD5.js"></script>
<script type="text/javascript" src="./script/requestTool.js"></script>
<script type="text/javascript" src="./script/common.js"></script>
<script type="text/javascript" src="./script/push.js"></script>
<!--<script type="text/javascript" src="./script/mui.min.js"></script>-->
<script type="text/javascript">
    var isChangeJituan = 0;
    //多集团下用户身份，0是学生，1是老师
    apiready = function () {
        if ($api.getStorage('cfnetppusericon') != '' && $api.getStorage('cfnetppusericon') != null) {
            $('#usericon').attr('src', $api.getStorage('cfnetppusericon'));
        }
        if ($api.getStorage('cfnetUserName')) {
            $('#user_name').text($api.getStorage('cfnetUserName'));
        } else {
            $('#user_name').text("暂无数据");
        }
        if ($api.getStorage('cfnetppjxidname')) {
            $('#user_school').text($api.getStorage('cfnetppjxidname'));
        } else {
            $('#user_school').text("暂无数据");
        }
        // loadJituan();
        //请求集团
        loaddata();
        initClick();
        initNotification();
        // alert($api.getStorage('cfnetppuid'));
        setupCache();
        //计算缓存
        //			isUserSignUp();
        //判断学霸赛是否报名
        isShowHongdian();
        initBaiduFaceSdk();
        if ($api.getStorage('cfnetSelectType') == 1) {
            $("#my_cfnetxingxing").show();
        }
        //设置我的应用
        setupUserApplication();
    };
	function initBaiduFaceSdk() {
		var zyBaiduFace = api.require('zyBaiduFace');
		var param = {
			"licenseID": api.systemType == "ios" ? 'xx-face-ios' : 'cfnet-face-android',
			"licenseFileName": api.systemType == "ios" ? 'idl-license.face-ios' : 'idl-license.face-android',
			"groupID": "users",
			"apiKey": "OrGWwZPvd4dBAmKTcGrHnVlf",
			"secretKey": "kofwTEb4kdRkF3xZ7dspFHdA7OKSkWIl",
		};
		zyBaiduFace.init(param, function (ret, err) {
		});
	}
    function tuichu() {
        cleanConfirm();
    }

    function setupUserType(userType) {
        var currentType = $api.getStorage('cfnetSelectType');
        if (userType == '1') {//老师
            $("#my_qiehuanshenfen").show();
            $("#my_shenfen").text(currentType == userType ? "教师" : "学生");
            if ($api.getStorage('cfnetppjxid') != '' && $api.getStorage('cfnetppjid') != '') {
                $('#my_shenqing').hide();
            } else {
                $('#my_shenqing').show();
            }
            $('#my_jifen').hide();
        } else {
            $('#my_shenqing').hide();
            $('#my_jifen').show();
            $("#my_qiehuanshenfen").hide();
        }
    }

    function loadJituan() {
        var dataXuexi = $api.getStorage('stdydata');
        if (dataXuexi != undefined && dataXuexi != null && dataXuexi.constructor == Array && dataXuexi.length >= 2) {
            $('#my_qiehuanjituan').show();
        }
    }

    function setupCache() {
        //获取缓存
        api.getCacheSize(function (ret, err) {
            if (ret) {
                var cacheSize = bytesToSize(parseInt(ret.size));
                // alert(JSON.stringify(cacheSize));
                $("#cacheValue").html(cacheSize);
            }
        });
    }

    // 字节转换
    function bytesToSize(bytes) {
        //alert(bytes);
        if ((bytes - 557424) <= 0)
            return '0 B';
        // if(bytes == 0) return '0 KB';
        var k = 1000;
        var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
        var i = Math.floor(Math.log(bytes) / Math.log(k));
        return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
    }

    function loaddata() {
        // showProgress();
        var url = urlApplst;
        var params = {
            uid: $api.getStorage('cfnetppuid'),
            jid: $api.getStorage('cfnetppjxid'),
        };
        cfnetppPOST(url, params, true, function (data, status) {
            hideProgress();
            if (status == 'success') {
                var jsonData = data.json;
                setupUserData(jsonData);
            } else {
                ShowToast("请检查网络");
            }
        });
    }

    function checkFace() {
        var zyBaiduFace = api.require('zyBaiduFace');
        var param = {
            "isLivenessRandom":true,//是否随机 检测动作  默认false
            "eye":true,//动作 眨眨眼    7个动作 请最少选择一种 不然就是7种按顺序执行
            "mouth":true,//动作 张张嘴
            "head_up":true,//动作 缓慢抬头
            "head_down":true,//动作 缓慢低头
            "left_right":false,//动作 摇摇头
            "isSound":true,//默认是否有提示音 默认true
        };
        zyBaiduFace.faceLive(param,function(ret, err){// ret.result.  bestimage0原始图片可存下来  headup  headleftorright headright mouth headdown headleft eye
            if(ret.status){
                registerFace(ret.result.bestimage0);

            }
        });
    }
    function registerFace(path) {
        var zyBaiduFace = api.require('zyBaiduFace');
        var param = {
            "user_id":$api.getStorage('cfnetppuid'),
            "name":$api.getStorage('cfnetUserName'),
            "filePath":path
        };
        zyBaiduFace.register(param, function(ret, err){
            //TODO 人脸认证
            zyBaiduFace.open({"user_id":$api.getStorage('cfnetppuid')}, function(ret, err){
                alert(JSON.stringify(ret));
            });
        });
    }
    function initClick() {
        $('#my_qiehuanshenfen').click(function () {
            api.actionSheet({
                buttons: ['教师', '学生']
            }, function (ret, err) {
                var index = ret.buttonIndex;
                $("#my_shenfen").text(index == 1 ? "教师" : "学生");
                $api.setStorage('cfnetSelectType', index == 1 ? 1 : 0);
                isChangeJituan = 1;
            });
        });
        $('#my_face').click(function () {
            api.requestPermission({
                list: ['camera', 'storage']
            }, function (result, err) {
                for (var i = 0; i < result.list.length; i++) {
                    if (!result.list[i].granted) {
                        return;
                    }
                }
                checkFace();
            });

        });
        $('#my_qiehuanjituan').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'TrainGroupListBothWindow',
                url: './html/Practice_Mine/TrainGroupListBothWindow.html',
                reload: true,
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#my_study').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'StudyFrom',
                url: 'StudyFrom.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#my_shezhi').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'PracticePlatfrom',
                url: 'PracticePlatfrom.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#my_renzheng').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'CertificationForm',
                url: 'CertificationForm.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#my_message').click(function () {
            api.openWin({
                useWKWebView: true,
                name: '',
                url: '',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#my_info').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'TrainSubmitUserInfo',
                url: './html/Practice_Mine/TrainSubmitUserInfo.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#my_cache').click(function () {
            $('#cleanCache').show();
        });
        $('#my_about').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'about',
                url: './html/Practice_Mine/about.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                }
            });
        });
        $('#suggestBack').click(function () {//反馈意见
            api.openWin({
                useWKWebView: true,
                name: 'suggestBack',
                url: './html/Practice_Mine/suggestBack.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                },
                slidBackEnabled: false,
            });
        });
        //我的竞赛
        $('#my_competition').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'MyCompetition',
                url: './html/Practice_Mine/MyCompetition.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                },
                slidBackEnabled: false,
                //					pageParam : {
                //						type : 1
                //					}
            });
        });
        //我的支付
        $('#my_pay').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'MyPay',
                url: './html/Practice_Mine/MyPay.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                },
                slidBackEnabled: false,
                pageParam: {
                    type: 1
                }
            });
        });
        $('#my_jifen').click(function () {//todo
            api.openWin({
                useWKWebView: true,
                name: 'MyAccumulatePoints_Win',
                url: './html/AccumulatePoints/MyAccumulatePoints_Win.html'
            });
        });
        //申请试用
        $('#my_shenqing').click(function () {//todo
            api.openWin({
                useWKWebView: true,
                name: 'changfengmoshiApply',
                url: 'html/changfengmoshiApply.html'
            });
        });
        //长风之星
        $('#my_cfnetxingxing').click(function () {
            $api.setStorage('iscfntxingxing', 1);
            $("#redPoint_xuexi_div1").hide();
            api.openWin({
                useWKWebView: true,
                name: 'MyCompetitionWindow',
                url: './html/Practice_Mine/MyCompetitionWindow.html',
                animation: {
                    type: "none", //动画类型（详见动画类型常量）
                    subType: "from_right", //动画子类型（详见动画子类型常量）
                    duration: 300 //动画过渡时间，默认300毫秒
                },
                slidBackEnabled: false,
                pageParam: {
                    type: 2
                }
            });
        });
        $('#my_PersonalTrajectory').click(function () {
            isUserType()
        });
        $('#my_application').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'MyApplication',
                url: 'MyApplication.html',
                slidBackEnabled: false
            });
        });
        //加入我们
        $('#my_join').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'joinUs',
                url: 'html/HomePage/joinUs.html'
            });
        });
    }

    //设置我的应用
    function setupUserApplication() {
        cfnetppPOST(url_getMyApplicationUrl, {uid: $api.getStorage('cfnetppuid')}, false, function (data, status) {
            if (status == 'success') {
                if (data.code == 200) {
                    $('#my_application').show();
                }
            }
        });
    }

    function setupUserData(data) {
        if (data == undefined) {//防止正式测试切换报错
            return;
        }
        $('#user_name').text(isString(data.username));
        $api.setStorage('cfnetUserName', data.username);
        $('#user_school').text(data.userschool);
        var userprofile = data.userprofile;
        if (userprofile != null) {
            $('#usericon').attr('src', HeadPortraitIsNull(userprofile));
            $api.setStorage('cfnetppusericon', userprofile);
        } else {
            $('#usericon').attr('src', HeadPortraitIsNull($api.getStorage('cfnetppusericon')));
        }
        //根据用户状态显示申请cell
        setupUserType(data.blocusertype);
    }

    function initNotification() {
        api.addEventListener({
            name: 'updateLeft'
        }, function (ret, err) {
            loaddata();
        });
        api.addEventListener({
            name: 'closeLeft'
        }, function (ret, err) {
            backToMain();
        });
        api.addEventListener({
            name: 'changeLeftMenuNotifi'
        }, function (ret, err) {
            // var userType=ret.value.userType;
            // if(userType==1){
            // 	//老师默认具有学生身份
            // 	$("#my_qiehuanshenfen").show();
            // 	$("#my_shenfen").text("教师")
            // }else {
            // 	$("#my_qiehuanshenfen").hide();
            // }
            loaddata();
            $('#user_school').text(ret.value.school);
            isChangeJituan = 1;
        });
        api.addEventListener({
            name: 'changeUserIconNotifi'
        }, function (ret, err) {
            if (ret) {
                $('#usericon').attr('src', $api.getStorage('cfnetppusericon'));
            }
        });
        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            backToMain();
        });
    }

    //取消
    function cleanCancel() {
        $('#offlineAlert').hide();
    }

    //确定
    function cleanConfirm() {
        //      $('#offlineAlert').hide();
        api.toast({
            msg: '退出登录成功',
            duration: 1000,
            location: 'bottom'
        });
        unbindAccount();
        $api.setStorage('cfnetppLoginStatus', 0);
        $api.setStorage('cfnetppusericon', "");
        $api.setStorage('cfnetUserName', "");
        $api.setStorage('cfnetppjxidname', "");
        $api.setStorage('stdydata', "");
        //清空学习集团
        $api.setStorage('practicedata', "");
        //清空实习集团
        $api.setStorage('cfnetpppassword', "");
        $api.setStorage('cfnetppuid', "");
        $api.setStorage('cfnetppjxid', "");
        $api.setStorage('cfnetSelectType', "");
        $api.setStorage('cfnetppusername', "");
        //退出环信
        var easeChat = api.require('easeChat');
        easeChat.logout(function (ret, err) {
        });
        api.closeWin({
            name: 'index',
            animation: {
                type: "none", //动画类型（详见动画类型常量）
                subType: "from_right", //动画子类型（详见动画子类型常量）
                duration: 100
            },
        });
        api.openWin({
            useWKWebView: true,
            name: 'login',
            url: 'login.html',
            slidBackEnabled: false,
            animation: {
                type: "none", //动画类型（详见动画类型常量）
                subType: "from_right", //动画子类型（详见动画子类型常量）
                duration: 100
            },
        });
        api.closeWin();
    }

    // 取消清除
    function cancleCache() {
        $("#cleanCache").hide();
    }

    // 确定清除
    function confirmCache() {
        $("#cleanCache").hide();
        api.clearCache(function (ret, err) {
            if (ret) {
                ShowToast("清除缓存成功！");
                $("#cacheValue").html("0 B");
            }
        });
    }

    function backToMain() {
        if (isChangeJituan == 1) {
            api.sendEvent({
                name: 'changeJidNotifi',
                extra: {
                    jid: $api.getStorage('cfnetppjxid'),
                }
            });
        }
        api.closeWin();
    }

    function replaceImg() {
        api.openWin({
            useWKWebView: true,
            name: 'TrainReplacePhoto',
            url: './html/Practice_Mine/TrainReplacePhoto.html',
            animation: {
                type: "none", //动画类型（详见动画类型常量）
                subType: "from_right", //动画子类型（详见动画子类型常量）
                duration: 300 //动画过渡时间，默认300毫秒
            },
            vScrollBarEnabled: false,
            hScrollBarEnabled: false,
        });
    }

    //判断头像是否为空
    function HeadPortraitIsNull(picurl) {
        var purl = "";
        if (picurl != '' && picurl != null) {
            if (picurl.indexOf("http") != -1) {//包含
                purl = picurl;
            } else {
                purl = $api.trimAll('http://cfnet.org.cn' + picurl);
            }
        } else {
            purl = "./icon/icon_default_HeadPortrait.png";
        }
        return purl;
    }

    //判断学生是否参加了学霸赛报名
    function isUserSignUp() {
        var params = {
            uid: $api.getStorage('cfnetppuid'),
            types: 61
        };
        cfnetppPOST(url_isUserSignUp, params, true, function (data, status) {
            //			api.hideProgress();
            if (status == 'success') {
                if (data.code == 200) {
                    aid = data.data.id;
                    //报名id
                    if (aid != '' && aid != null) {
                        $('#my_competition').show();
                        //
                    } else {
                        $('#my_competition').hide();
                        //未报名状态
                    }
                } else {
                    $('#my_competition').hide();
                    //未报名状态
                }
            } else {
                $('#my_competition').hide();
            }
        });
    }

    //是否显示红点
    function isShowHongdian() {
        if ($api.getStorage('iscfntxingxing') == 1) {
            $("#redPoint_xuexi_div1").hide();
        }
    }

    //判断用户在多集团下的身份,只要存在一个老师身份,当前用户视为老师身份
    function isUserType() {
        var params = {
            uid: $api.getStorage('cfnetppuid'),
        };
        cfnetppPOST(url_checkUserRole, params, true, function (data, status) {
            if (status == 'success') {
                if (data.code == 200) {
                    var type = 0;
                    var list = data.data;
                    for (var i = 0; i < list.length; i++) {
                        if ((list[i].role) == 1) {
                            type = 1;
                            break;
                        }
                    }
                    openPersonalTrajectoryFrame(type)

                } else {
                }
            } else {
            }
        });
    }

    function openPersonalTrajectoryFrame(userTypeStr) {
        if (userTypeStr == 1) {//老师身份
            api.openWin({
                useWKWebView: true,
                name: 'PersonalTrajectory_Teacher_Win',
                url: 'html/PersonalTrajectory/PersonalTrajectory_Teacher_Win.html',
            });
        } else if (userTypeStr == 0) {//学生身份
            api.openWin({
                useWKWebView: true,
                name: 'PersonalTrajectory_Student',
                url: 'html/PersonalTrajectory/PersonalTrajectory_Student.html',
            });
        }
    }
</script>
</html>